//package com.example.waibao.config.scheduled;
//
//import com.example.waibao.service.UserService;
//import com.example.waibao.service.impl.ScheduledService;
//import com.example.waibao.service.taskService;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.scheduling.support.CronTrigger;
//import org.springframework.scheduling.support.SimpleTriggerContext;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.time.Duration;
//import java.time.LocalDateTime;
//import java.util.Date;
//
///**
// * @Author whh
// * @Date: 2023/03/15/ 19:46
// * @description
// * 任务的抽象类
// * 用于做切面打印任务执行的时间，耗时等信息
// */
//
//@Component
//public class ITask implements Runnable{
//
//    @Autowired
//    private ScheduledService scheduledService;
////    @Autowired
////    private UserService userService;
////
////    @Autowired
////    private com.example.waibao.service.taskService taskService;
//
//    private static final Logger LOGGER = LoggerFactory.getLogger("ITask");
//    private String cron="*/10 * * * * ?";
//    private String taskName="监控任务";
//    private String taskDescription="每隔30s对机器进行监控";
//
////    public ITask(String cron) {
////        this.cron = cron;
////    }
//
//    @Override
//    public void run() {
//        LocalDateTime start = LocalDateTime.now();
//        try {
//              System.out.println( "任务开始");
//              scheduledService.scheduled();
//        } catch (IOException e) {
//            throw new RuntimeException(e);
//        }
//        LocalDateTime end = LocalDateTime.now();
//        Duration duration = Duration.between(start, end);
//        long millis = duration.toMillis();
//        Date date = new CronTrigger(this.cron).nextExecutionTime(new SimpleTriggerContext());
//        LOGGER.info("任务：[{}]执行完毕，开始时间：{}，结束时间：{}，耗时：{}ms，下次执行时间{}",this.taskName, start,end,millis,date);
//    }
//
//
//    /**
//     * 用户的任务实现
//     */
////    public void execute() throws IOException {
////        System.out.println( "任务开始");
////        scheduledService.scheduled();
////    }
//
//
//    public String getCron() {
//        return cron;
//    }
//
//    public void setCron(String cron) {
//        this.cron = cron;
//    }
//
//    public String getTaskName() {
//        return taskName;
//    }
//
//    public void setTaskName(String taskName) {
//        this.taskName = taskName;
//    }
//
//    public String getTaskDescription() {
//        return taskDescription;
//    }
//
//    public void setTaskDescription(String taskDescription) {
//        this.taskDescription = taskDescription;
//    }
//}
//
//
